﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TwKarma.Web.App
{
    public partial class Profile : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["For"] == null)
                Response.Redirect("default.aspx");
            
            KarmaService.Votes service = new KarmaService.Votes();
			KarmaService.TwitterUser user = service.UserKarma(Request.QueryString["For"]);
            if (user == null)
                Response.Redirect("default.aspx");

            Page.Title = "#TwKarma for " + user.ScreenName;

			litScreenname.Text = user.ScreenName;
			litKarma.Text = String.Format("<span class=\"{0}\">{1}{2}</span>", GoodBadIndifferent(user.Score), Sign(user.Score), Math.Abs(user.Score));

            litAboutName.Text = "About @" + user.ScreenName;
			
        }

		private string Sign(int score)
		{
			if (score == 0)
				return string.Empty;

			return score > 0 ? "+" : "-";
		}
		private string GoodBadIndifferent(int score)
		{
			if (score == 0)
				return "indifferent";

			return score > 0 ? "good" : "bad";
		}
    }
}